#include<cstdio>
#define LL long long
const LL MAXK=1000000;
const LL MAXN=1000000000000;
LL n;

LL fac(int k,int r)
{
	LL ans=k;
	LL tem=k;
	for(int i=2;i<=r;i++)
	{
		tem=tem*k;
		if(tem>MAXN)return MAXN+1;
		ans=ans+tem;
		if(ans>MAXN)return MAXN+1;
	}
	return ans;
}

int find(int r)
{
	int L=2,R=MAXK;
	while(L<=R)
	{
		int mid=(L+R)/2;
		LL tem=fac(mid,r);
		if(tem==n||tem==n-1)return mid;
		if(tem>n)R=mid-1;
		else L=mid+1;
	}
	return -1;
}
int main()
{
	while(scanf("%lld",&n)!=EOF)
	{
		int ansr=1;
		LL ansk=n-1;
		for(int i=2;i<=40;i++)
		{
			int k=find(i);
			if(k>0&&k*i<ansk*ansr)
			{
				ansk=k;
				ansr=i;
			}
		}
		printf("%d %lld\n",ansr,ansk);
	}
	return 0;
}

